extends ../wechat/wechat

block content
    butto#button 点击标题开始录音
    div#director
    div#year
    div#poster

    script.
        wx.config({
            debug: true, 
            appId: 'wx428a2aec154c5a9c', 
            timestamp: '#(timestamp)', 
            nonceStr: '#(noncestr)', 
            signature: '#(signature)',
            jsApiList: [
                'startRecord',
                'stopRecord',
                'onVoiceRecordEnd',
                'translateVoice'
            ] 
        });
        wx.ready(function(){
            var isRecording = false
            $('#button').on('click',function(){
                if(!isRecording){
                    isRecording = true
                    wx.startRecord({
                        cancel: function(){
                            window.alert('不搜了')
                        }
                    });
                    return
                }
                isRecording = false
                wx.stopRecord({
                    success: function (res) {
                        var localId = res.localId;
                        wx.translateVoice({
                           localId: localId, 
                            isShowProgressTips: 1, // 默认为1，显示进度提示
                            success: function (res) {
                                alert(res.translateResult); // 语音识别的结果
                            }
                        });
                    }
                });
            })
        })